package com.hhkj.study.api.article.biz.impl;

import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.hhkj.study.admin.article.entity.Article;
import com.hhkj.study.admin.article.service.base.ArticleService;
import com.hhkj.study.api.article.biz.ApiArticleBizService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @Author luowu
 * @Date 2024/10/8 涵 11:56:06
 */
@Service
public class ApiArticleBizServiceImpl implements ApiArticleBizService {

    @Resource
    private ArticleService articleService;

    @Override
    public boolean downloadArticle(Long id) {
        LambdaUpdateWrapper<Article> articleUpdate = new LambdaUpdateWrapper<>();
        articleUpdate.eq(Article::getId, id).setSql("read_amount = read_amount + 1");
        return articleService.update(articleUpdate);
    }
}
